﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ITAP.ContourBuilder.Manipulation;
using System.Drawing;

namespace ITAP.ContourBuilder.Operations
{
    public abstract class Operation : IOperation
    {
        #region IOperation Members
        public virtual bool CanUndo
        {
            get { throw new NotImplementedException(); }
        }

        private bool enabled = true;
        public virtual bool Enabled
        {
            get
            {
                return enabled;
            }
            set
            {
                enabled = value;
            }
        }

        public virtual void ObtainPeripheryState(GlobalPeripheryState state)
        {
        }

        public void DrawOnGraphics(Graphics g, int screenWidth, int screenHeight, System.Drawing.RectangleF modelRectangle, ITAP.Core.Modelling.ModelPoint cameraCenter, ITAP.Core.Calculations.ModelCoordinateConverter coordinateConverter)
        {
        }

        public event OperationEvent OperationEvent;

        #endregion

        #region IExecutable Members

        private ContourControl control;
        public ContourControl Control
        {
            get
            {
                return control;
            }
            set
            {
                control = value;
            }
        }

        public virtual void Execute()
        {
        }

        public void Exit()
        {           
            this.OperationEvent.Invoke(this, OperationEventState.EndExecute);
        }

        public virtual Bitmap Icon
        {
            get { return null; }
        }

        #endregion

        #region IOperation Members

        public virtual string Name
        {
            get { throw new NotImplementedException(); }
        }

        #endregion

        #region IExecutable Members


        public virtual void Cancel()
        {
            this.OperationEvent.Invoke(this, OperationEventState.Canceled);
        }

        #endregion

        #region IExecutable Members

        public event ManipulatorEvent StateChanged;

        #endregion

        #region ICloneable Members

        public object Clone()
        {
            IExecutable clone = (IExecutable)Activator.CreateInstance(this.GetType());
            clone.Control = this.control;
            
            return clone;
        }

        #endregion
    }
}
